package servlets;

import java.io.IOException;
import java.io.PrintWriter;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import servicios.OficinaService;

public class BuscarOficinaServlet extends HttpServlet {
	
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		resp.sendRedirect("oficina/buscar.html");
	}
	
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		String name = req.getParameter("name");
		System.out.println(name);
		new OficinaService().buscarOficina(name);
		/*
		* Set the content type(MIME Type) of the response.
		*/
		resp.setContentType("text/html");
		 
		PrintWriter out = resp.getWriter();
		/*
		* Write the HTML to the response
		*/
		out.println("<html>");
		out.println("<head>");
		out.println("<title> Una oficina</title>");
		out.println("</head>");
		out.println("<body>");
		out.println("<h1>Simple Oficina</h1>");
		out.println("<label>Entro a ver solo una oficina de nombre: "+name + "</label>");
		out.println("<div>");
		out.println("<a href='home/index.html'>volver la menu</a>");
		out.println("</div>");
		out.println("</body>");
		out.println("</html>");
		out.close();
	}
}
